//package com.chixing.controller;
//
//import com.chixing.pojo.Myorder;
//import com.chixing.pojo.Shop;
//import com.chixing.service.BranchService;
//import com.chixing.service.CarService;
//import com.chixing.util.DateUtil;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.servlet.ModelAndView;
//
//import java.util.Date;
//
//import static com.chixing.util.DateUtil.DATE_PATTERN_YMDHM;
//
//@Controller
//public class CreateOrderController {
//    @Autowired
//    private CarService carService;
//
//    @Autowired
//    private BranchService branchService;
//
//
//
//    @GetMapping("/order/{cusId}/{carId}/{getCarShop}/" +
//            "{returnCarShop}/{startDate}/{endDate}/{carName}/{price}/{getCity}/{returnCity}")
//    @ResponseBody
//    public ModelAndView getOrderInfo(@PathVariable("cusId") Integer cusId, @PathVariable("carId") Integer carId,
//                                     @PathVariable("getCarShop") String getCarShop, @PathVariable("returnCarShop") String returnCarShop,
//                                     @PathVariable("startDate") String startDate, @PathVariable("endDate") String endDate,
//                                     @PathVariable("carName") String carName, @PathVariable("price") Float price,
//                                     @PathVariable("getCity") String getCity, @PathVariable("returnCity") String returnCity) {
//
//        System.out.println("cusId:" + cusId);
//        System.out.println("carId:" + carId);
//        System.out.println("getCarShop:" + getCarShop);
//        System.out.println("returnCarShop:" + returnCarShop);
//        System.out.println("startDate:" + startDate);
//        System.out.println("endDate:" + endDate);
//        System.out.println("carName:" + carName);
//        System.out.println("price:" + price);
//
//        startDate.replace(":", "-");
////        System.out.println(startDate);
//        Date getCarDate = DateUtil.string2Date(startDate, DATE_PATTERN_YMDHM);
////        System.out.println(getCarDate);
//
//        endDate.replace(":", "-");
//
//        Date returnDate = DateUtil.string2Date(endDate, DATE_PATTERN_YMDHM);
//        Myorder myorder = new Myorder();
//
//        //租车天数
//        int day = (int) (returnDate.getTime() - getCarDate.getTime()) / (24 * 60 * 60 * 1000);
//
//        int startShopId = branchService.getByNameCity(getCarShop, getCity).getShopId();
//        int endShopId = branchService.getByNameCity(returnCarShop, returnCity).getShopId();
//
//        ModelAndView mav = new ModelAndView();
//
//        if (branchService.getByNameCity(getCarShop, getCity) == null) {
//            mav.addObject("result", "您所选择的店铺不存在");
//            mav.setViewName("car_rental/car-search");
//            System.out.println(mav);
//            return mav;
//        }
//
//
//        myorder.setMemberId(cusId);//用户id
//        myorder.setGetShopId(startShopId);//取车萌呆呢id
//        myorder.setReturnShopId(endShopId);//还车门店id
//        myorder.setGetCarDate(getCarDate);//取车时间
//        myorder.setBackCarDate(returnDate);//还车时间
//        myorder.setCarId(carId);//车辆id
//        myorder.setCarDay(day);//租车天数
//        myorder.setMyorderRawprice(price);//原始价格
//        myorder.setMyorderTotalPrice(day * price); //总价格
//
//        String startAdd = branchService.getAddById(startShopId);// 取车地址
//        String endAdd = branchService.getAddById(endShopId);// 还车地址
//
//
//        mav.addObject("orderInfo", myorder);
//        mav.addObject("carName", carName);
//        mav.addObject("startDate", startDate);
//        mav.addObject("endDate", endDate);
//        mav.addObject("getCarShop",getCarShop);
//        mav.addObject("returnCarShop",returnCarShop);
//        mav.addObject("startAdd",startAdd);
//        mav.addObject("endAdd",endAdd);
//        mav.setViewName("order/create_order");
//
//        System.out.println("订单详情");
//        System.out.println(mav);
//
//        return mav;
//    }
//
//
//}
